<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>List Renders</title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
</head>
<body>

<div>
<!--

    enter
    tab
    delete (捕获 “删除” 和 “退格” 键)
    esc
    space
    up
    down
    left
    right

-->

    <form id="onSubmit" v-on:submit.prevent="onSubmit">v-on:submit.prevent
        <!-- 只有在 keyCode 是 13 时调用 vm.submit() -->
        <input v-on:keyup.13="onSubmit" value="keyup.13">
        <!-- 同上 -->
        <input v-on:keyup.enter="onSubmit" value="enter">
        <!-- 缩写语法 -->
        <input @keyup.delete ="onSubmit" value="delete">
        <input @keyup.down="onSubmit" value="down">

        <!--检测keyup不生效-->
        <input v-on:keyup.v="v" value="v">

    </form>


</div>


<script>

    var onSubmitVm = new Vue({
        el: '#onSubmit',
        data: {},
        methods: {
            onSubmit: function () {
                alert("in onSubmit")
            }
        }
    })

    // 可以通过全局 config.keyCodes 对象自定义按键修饰符别名：
    // 可以使用 v-on:keyup.f1
    Vue.config.keyCodes = {
        "v": 86,
        'f1': 112,
        'P': 80
    }

</script>
</body>
</html>
